using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace QuanLyNganHangDe.DAL.Models.Mapping
{
    public class DotThiMap : EntityTypeConfiguration<DotThi>
    {
        public DotThiMap()
        {
            // Primary Key
            this.HasKey(t => t.MaDotThi);

            // Properties
            this.Property(t => t.MaDotThi)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.TenDotThi)
                .IsRequired()
                .HasMaxLength(255);

            this.Property(t => t.MaHocKy)
                .IsRequired()
                .HasMaxLength(50);

            this.Property(t => t.GhiChu)
                .HasMaxLength(255);

            // Table & Column Mappings
            this.ToTable("DotThi");
            this.Property(t => t.MaDotThi).HasColumnName("MaDotThi");
            this.Property(t => t.TenDotThi).HasColumnName("TenDotThi");
            this.Property(t => t.MaHocKy).HasColumnName("MaHocKy");
            this.Property(t => t.NgayBatDauThi).HasColumnName("NgayBatDauThi");
            this.Property(t => t.GhiChu).HasColumnName("GhiChu");

            // Relationships
            this.HasRequired(t => t.HocKy)
                .WithMany(t => t.DotThiCollection)
                .HasForeignKey(d => d.MaHocKy);

        }
    }
}
